package com.lonely.order.enums;

import com.lonely.common.exception.BusinessException;
import lombok.Getter;

/**
 * @author: 黄志标
 * @date: 2025/6/24 9:32
 * @description: 订单日志相关枚举
 */
public class OrderLogEnum {


    /**
     * 日志类型枚举
     */
    @Getter
    public enum LogTypeEnum {

        /**
         * 状态
         */
        STATUS(1),

        /**
         * 备注
         */
        NOTES(2);

        /**
         * 日志类型
         */
        private final int type;

        LogTypeEnum(int type) {
            this.type = type;
        }


        /**
         * 根据类型获取枚举
         *
         * @param type
         * @return
         */
        public static LogTypeEnum getInstance(int type) {
            for (LogTypeEnum logTypeEnum : LogTypeEnum.values()) {
                if (logTypeEnum.getType() == type) {
                    return logTypeEnum;
                }
            }
            throw new BusinessException(String.format("订单日志类型：%s 对应的枚举不存在", type));
        }
    }

}
